package com.arvato.wxwork.service.kpi;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.arvato.minipro.bean.bean_dto.common.PageData;
import com.arvato.minipro.bean.bean_dto.common.Query;
import com.arvato.wxwork.bean.bean_do.kpi.WxworkKpiSetDo;
import com.arvato.wxwork.bean.bean_vo.kpi.WxworkKpiSetVo;
import com.arvato.wxwork.mapper.kpi.WxworkKpiSetMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * kpi设定service
 * @author ZHAN655
 *
 */
@Service
@Transactional
public class WxworkKpiSetService {
	
	@Autowired
	private WxworkKpiSetMapper wxworkKpiSetMapper;
	
	/**
	 * 查询kpi设定列表 分页查询
	 * @param query
	 * @param integer 
	 * @return
	 */
	public PageData listKpiSetByQuery(Query query, Integer pageNum, Integer pageSize) {
		// 设置分页参数
		PageHelper.startPage(pageNum, pageSize);
		List<WxworkKpiSetVo> areaList = wxworkKpiSetMapper.listKpiSetByQuery(query);
		PageInfo<WxworkKpiSetVo> pageInfo = new PageInfo<WxworkKpiSetVo>(areaList);
		PageData pageData = new PageData(pageInfo.getTotal(), pageInfo.getList());
		return pageData;
	}
	
	/**
	 * 根据ID查询详情
	 * @param areaId
	 * @return
	 */
	public WxworkKpiSetVo getKpiSetById(String areaId) {
		return wxworkKpiSetMapper.getKpiSetById(areaId);
	}
	
	/**
	 * 创建kpi
	 * @param KpiSetDo
	 */
	public int insert(WxworkKpiSetDo KpiSetDo) {
		return wxworkKpiSetMapper.insert(KpiSetDo);
	}
		
	/**
	 * 修改kpi
	 * @param KpiSetDo
	 * @return
	 */
	public int update(WxworkKpiSetDo KpiSetDo) {
		return wxworkKpiSetMapper.update(KpiSetDo);
	}
	/**
	 * 删除kpi
	 * @param KpiSetId
	 * @return
	 */
	public int delete(String KpiSetId) {
		return wxworkKpiSetMapper.delete(KpiSetId);
	}
	
}
